<template>
  <div class="home">
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="title" label="标题" width="180"> </el-table-column>
      <el-table-column prop="content" label="内容" width="180"> </el-table-column>
      <el-table-column prop="create_time" label="添加时间" :formatter='formatterDate'> </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {getList} from '@/api/index.js';
// @ is an alias to /src
import HelloWorld from "@/components/HelloWorld.vue";

export default {
  name: "Home",
  components: {
    HelloWorld,
  },
  data () {
    return {
      tableData:[],
    }
  },
  methods: {
    getList(){
      getList({}).then((res)=>{
        // console.log(res);
        let {data:{newsList}}=res;
        this.tableData=newsList;
      })
    },
    formatterDate(row,column){
      return this.formatDate(new Date(row.create_time),'yyyy-MM-dd');
    }
  },
  created () {
    this.getList();
  }
};
</script>
